Skip to main content

For Each Data Row

AutomatR.DefaultActivities.Datatable.ForEachDataRow

The "For Each Data Row" activity in AutomatR facilitates iterating through each row in a specified DataTable variable, allowing users to execute actions on individual rows within the DataTable. This activity is especially useful for scenarios where specific operations need to be performed on each row of a DataTable.

Properties

NameDescription
Input
Data TableSpecifies the DataTable variable on which an action is to be executed once for each row. DataTable variables containing the data table to be iterated.
Misc
Display NameProvides a customizable name for the activity displayed in the workflow. The display name enhances clarity and organization within the automation project. String variables containing the desired display name.
VariablesThe numerical value used to identify the position of an element within a collection or array.

Variables:

  • Index: An internal variable that keeps track of the current iteration index. It can be accessed in the workflow for further use.

Break and Continue:

  • This activity supports the use of break and continue bookmarks, allowing users to control the flow of execution within the loop. Break and continue bookmarks can be used to interrupt the loop or skip to the next iteration based on specific conditions.

How to use:

  1. Drag and drop the "For Each Data Row" activity onto the workflow.
  2. Configure the properties by specifying the DataTable variable on which the action will be executed for each row.
  3. Optionally, configure the display name.
  4. Use the body of the activity to define the action to be performed on each DataRow.

Example: Consider an example where the "For Each Data Row" activity is used to iterate through a DataTable named "employeeData" and print the values of the "Name" column for each row:

For Each Data Row:
Data Table: employeeData
Body:
Write Line: "Employee Name: " + row["Name"].ToString()

In this example, the activity iterates through each row in the "employeeData" DataTable, and for each row, it executes the defined action in the body (printing the employee name). Adjust the input properties and body of the activity based on your specific requirements.

Break and Continue:

  • Break and continue bookmarks can be used to control the loop flow. To use them, create a bookmark variable in your workflow, configure it in the "For Each Data Row" activity, and use it in your workflow logic.

Variables Usage:

  • The "Index" variable can be accessed in the workflow after the loop execution to retrieve the total number of iterations.